package mashuaiproject.mashuaiproject.mapper;

import mashuaiproject.mashuaiproject.model.*;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Component
public interface OtherMapper {
    @Select("select *from selfxunzhang where user_id=#{userId}")
    List<SelfXunzhang> selectOneXunzhang(@Param("userId") Integer userId);
    @Select("select *from xunzhang where id=#{id}")
    XunZhang selectOneXZmes(@Param("id") Integer xunzhangId);
    @Select("select count(1) from quesions where creator=#{userId}")
    Integer selecBokeCount(@Param("userId") Integer userId);

    @Select("select count(1) from save where user_id=#{userId}")
    Integer selecSaveCount(@Param("userId") Integer userId);

    @Select("select count(1) from guanzhu where user_id=#{userId} and bozhu_id!=#{userId}")
    Integer selecGuanzhuCount(@Param("userId") Integer userId);

    @Select("select count(1) from comment where user_id=#{userId}")
    Integer selecCommentCount(@Param("userId") Integer userId);

    @Select("select count(1) from guanzhu where user_id=#{userId} and bozhu_id=#{bozhu_id}")
    Integer JudegIsGuanhu(@Param("bozhu_id") Integer userId, @Param("userId") Integer cunrretId);

    @Update("update users set chenwei=#{chengwei} where id=#{currentUserId}")
    Integer upadteChengWei2(@Param("currentUserId") Integer currentUserId, @Param("chengwei") String  chengwei);

    @Select("select name from xunzhang where id=#{xunzhangId}")
    String selectChengWei(@Param("xunzhangId") Integer xunzhangId);

    @Select("select  *from save where user_id=#{user_id} and father_id!=#{user_id}")
    List<Save> selectSaveQueisons(@Param("user_id") Integer userId);
    @Select("select  count(1) from save where user_id=#{user_id} and father_id!=#{user_id}")
    Integer selectSaveNoSelf(@Param("user_id") Integer userId);

    @Select("select  count(1) from guanzhu where bozhu_id=#{user_id} and user_id!=#{user_id}")
    Integer selectFensiCount(@Param("user_id") Integer userId);

    @Select("select   *from guanzhu where user_id=#{user_id} and bozhu_id!=#{user_id}")
    List<GuanZhu> selectGuanzhuUsers(@Param("user_id") Integer userId);
    @Select("select   *from guanzhu where bozhu_id=#{user_id} and user_id!=#{user_id}")
    List<GuanZhu> selectFensiUser(@Param("user_id") Integer userId);

    @Select("select  *from xunzhang")
    List<XunZhang> selectAllXunZhang();
    @Select("select  *from xunzhang where id=#{id}")
    XunZhang selectJudegXUnzhng(@Param("id") Integer xunzhang_id);
    @Select("select  count(1) from selfxunzhang where xunzhang_id=#{id}")
    Integer selectGetOneCoung(@Param("id") Integer xunzhangId);
    @Select("select  count(1) from comment where commentator=#{id}")
    Integer selecCommentCOunt(@Param("id") Integer id);
    @Select("select  count(1) from quesions where creator=#{id}")
    Integer selectFabuQUeison(Integer id);

    @Insert("insert into selfxunzhang (user_id,xunzhang_id) values(#{user_id},#{xunzhang_id})")
    Integer insertXZ(@Param("user_id") Integer id, @Param("xunzhang_id") Integer xzId);
//增加积分
    @Update("update users set jifen=jifen+#{i} where id=#{id}")
    Integer updateJifen(@Param("id") Integer id, @Param("i") int i);
    @Update("update users set exp=exp+#{i} where id=#{id}")
    Integer updateExp(@Param("id") Integer id, @Param("i") int i);
    @Update("update users set weiwang=weiwang+#{i} where id=#{id}")
    Integer updateWeiwang(@Param("id") Integer id, @Param("i") int i);
    @Select("select  creator from quesions where id=#{id}")
    Integer selectBoZhuId(Integer boZhuId);

    @Insert("insert into dongtai (userId,type,content,gmt_create) values(#{userId},#{type},#{content},#{gmt_create})")
    Integer insertDongTai(Dongtai dongtai);
    @Select("select  *from  dongtai where  userId= #{id} group by gmt_create desc")
    List<Dongtai> selectOneDongTai(@Param("id") Integer id);

    @Delete("delete   from dongtai where  id=#{delId}")
    Integer delDongtai(@Param("delId") Integer id);
    @Select("select  *from  selfxunzhang where  user_id= #{id} and xunzhang_id=#{i}")
    Integer selectIsHasSlefXZ(@Param("id") Integer id, @Param("i") int i);
}
